{% extends "devhub/base.html" %}

{% set title = _('Email Address Verification') %}

{% block title %}{{ dev_page_title(title) }}{% endblock %}

{% block content %}
<h1>{{ title }}</h1>
<div class="verify-email" id="{{ state }}">
<strong>{{ _('Status:') }}</strong>
{% if state == "email_verified" %}
  {% trans %}
  Your email address is verified.
  {% endtrans %}
{% elif state == "email_suppressed" %}
  {% trans %}
  Please verify your email.
  {% endtrans %}
{% elif state == "verification_expired" %}
  {% trans %}
  Could not verify email address. The verification link has expired.
  {% endtrans %}
{% elif state == "verification_pending" %}
    {% trans %}
    We are sending an email to you, please be patient...
    <div class="loader"></div>
    The page will automatically refresh.
    {% endtrans %}
{% elif state == "verification_timedout" %}
  {% trans %}
  It is taking longer than expected to confirm delivery of your verification email. Please try again later.
  {% endtrans %}
{% elif state == "confirmation_pending" %}
  <h3>{{ _('Success!') }}</h3>
  {% trans email=request.user.email %}
  An email with a confirmation link has been sent to your email address: {{ email }}. Please click the link to confirm your email address. If you did not receive the email, please check your spam folder.
  {% endtrans %}
{% elif state == "confirmation_invalid" %}
  {% trans email=request.user.email %}
  The provided code is invalid, unauthorized, expired or incomplete. Please use the link in the email sent to your email address {{ email }}. If the code is still not working, please request a new email.
  {% endtrans %}
{% endif %}
</div>


{% if render_table %}
<div class="verify-email-table">
  <p>
    {% trans %}
      <strong>Email history:</strong> The table below shows all emails we have attempted to send to you in the last 2 days.
    {% endtrans %}
  </p>
  <table border=1 frame=void rules=rows>
    {% if found_emails|length > 0 %}
      <thead>
        <tr>
          <th>{{ _('Date') }}</th>
          <th>{{ _('From') }}</th>
          <th>{{ _('To') }}</th>
          <th>{{ _('Subject') }}</th>
          <th>{{ _('Status') }}</th>
        </tr>
      </thead>
      <tbody>
      {% for email in found_emails %}
        <tr>
          <td>
            {{ email.statusDate }}
          </td>
          <td>
            {{ email.from }}
          </td>
          <td>
            {{ email.to }}
          </td>
          <td>
            {{ email.subject }}
          </td>
          <td>
            {{ email.status }}
          </td>
        </tr>
      {% endfor %}
      </tbody>
    {% else %}
      <tbody>
        <td>{{ _('We have not found any email records for you in the last 2 days.') }}</td>
      </tbody>
    {% endif %}
  </table>
  <a href="{{ request.get_full_path() }}">{{ _('Refresh results') }}</a>
</div>
{% endif %}


{% if render_button %}
<div class="verify-email-actions">
{% with submit_text=button_text %}
  {% include 'devhub/verify_email_form.html' %}
{% endwith %}
{% trans a_attrs='target="_blank" rel="noopener noreferrer" href="%s/documentation/publish/developer-accounts/#email-issues?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=devhub"'|format(settings.EXTENSION_WORKSHOP_URL)|safe%}
  If you encounter issues, please see our <a {{ a_attrs }}>troubleshooting suggestions</a> on Firefox Extension Workshop.
{% endtrans %}
</div>
{% endif %}
{% endblock %}
